package com.ruoyi.system.service.impl;


import com.ruoyi.common.core.domain.entity.DocTemp;
import com.ruoyi.common.core.domain.entity.DocTempManage;
import com.ruoyi.system.domain.vo.TempVo;
import com.ruoyi.system.mapper.DocTempMapper;
import com.ruoyi.system.service.DocTempService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.Date;
import java.util.List;

@Service
public class DocTempServiceImpl implements DocTempService {

    @Autowired
    private DocTempMapper docTempMapper;
    /**
     * 查询项目模板信息列表
     */
    @Override
    public List<TempVo> selectDocTempManageList(DocTempManage docTempManage) {


        List<TempVo> returnList = docTempMapper.selectDocTempManageList(docTempManage);
        //单独查询模板名称
        List<DocTempManage> list = docTempMapper.selectTempName(docTempManage);
        for (DocTempManage  docTempManageList : list){
            for (TempVo tempVo : returnList){
                tempVo.setTempName(docTempManageList.getTempName());
            }
        }
        return returnList;
    }
    /**
     * 添加项目模板信息列表
     */
    @Override
    public int insertDocTempManage(DocTempManage docTempManage) {
        Date date = new Date();
        docTempManage.setUploadTime(date);
        return docTempMapper.insertDocTempManage(docTempManage);
    }

    /**
     * 修改项目模板信息列表
     */
    @Override
    public int updateDocTempManage(DocTempManage docTempManage) {
        return docTempMapper.updateDocTempManage(docTempManage);
    }

    /**
     * 删除项目模板信息列表
     */
    @Override
    public int deleteDocTempManageByTempIds(Long[] tempId) {
        return docTempMapper.deleteDocTempManageByTempIds(tempId);
    }

    /**
     * 上传文件  添加文件存储路径 url 文件唯一标识
     */
    @Override
    public Long insertPathName(DocTemp docTemp) {
        docTempMapper.insertPathName(docTemp);
        return docTemp.getFileTempId();
    }


}
